package com.kaifamiao.www.demo.do0826;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

public class Demo03 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("a",1);
        map.put("b",2);
        map.put("c",3);
        map.put("d",4);
        map.put("e",5);
        //键
        Stream<String> stream = map.keySet().stream();
        //值
        Stream<Integer> stream1 = map.values().stream();
        //键值对
        Stream<Map.Entry<String,Integer>> stream2 = map.entrySet().stream();

        stream2.filter(s -> s.getValue()>2)
                .forEach(s -> System.out.println(s));
        String[] strs = {"张家辉","张学友","周杰伦","古天乐","周润发","黎明","刘德华","张天"};
        Stream<String> stream3 = Arrays.stream(strs);
        stream3.filter(s -> s.startsWith("张"))
                .skip(1)//跳过一位
                .limit(2)//只输出两位
                .forEach(s ->
                        System.out.println(s));
    }

}
